<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>修改密码</title>
    <link rel="stylesheet" href="/static/css/hui.css">
</head>

<body>

    <header class="hui-header">
        <div id="hui-back"></div>
        <h1>密码修改</h1>
    </header>

    <div class="hui-list-text">账号：{{account}}</div>

    <form id="form1" class="hui-form" style="padding:28px 10px;" enctype="multipart/form-data">
        <div class="hui-form-items">
            <div class="hui-form-items-title">原密码</div>
            <input type="password" class="hui-input hui-pwd-eye" placeholder="填写原密码" checktype="passWord" id="oldPW" checkmsg="密码应由字母和数字组成的6-12个字符">
            <div class="hui-pwd-eyes" onclick="hui.eyesChange(this);"></div>
        </div>

        <div class="hui-form-items">
            <div class="hui-form-items-title">新密码</div>
            <input type="password" class="hui-input hui-pwd-eye" placeholder="填写新密码" checktype="passWord" id="newPW" checkmsg="密码应由字母和数字组成的6-12个字符 ">
            <div class="hui-pwd-eyes " onclick="hui.eyesChange(this); "></div>
        </div>
        <div class="hui-form-items">
            <div class="hui-form-items-title">确认密码</div>
            <input type="password" class="hui-input hui-pwd-eye" placeholder="确认新密码" checktype="sameWithId" checkdata="newPW" checkmsg="两次密码不一致">
            <div class="hui-pwd-eyes" onclick="hui.eyesChange(this);"></div>
        </div>
        <div style="padding:15px 8px;">
            <button type="button" class="hui-button hui-button-large hui-primary" id="submit">提交</button>
        </div>
    </form>
    <div style="text-align: center ">
        <a href="/forgetPW/ ">忘记原密码?</a>
    </div>


    <script type="text/javascript" src="/static/js/hui.js"></script>
    <script type="text/javascript" src="/static/js/hui-form.js"></script>

    <script>
        hui('#submit').click(function () {
            //表单验证
            hui.formInit();
            var res = huiFormCheck('#form1');
            if (res) {
                var oldPW = hui('#oldPW').val()
                var newPW = hui('#newPW').val()
                hui.postJSON(
                    'http://127.0.0.1:5000/setPW/',
                    { oldPW: oldPW, newPW: newPW },
                    function (res) {
                        hui.alert(res.message, '好的', function () {
                            if (res.code == 1) {
                                window.location.href = 'http://127.0.0.1:5000/userSet/'
                            }
                        });
                    },
                    function (e) {
                        hui.iconToast('读取消息失败', 'warn');
                    }
                );
            }

        });
    </script>

</body>

</html>